<?php
$scriptWindowMsg = "
    $(function() {
        $('a#close').click(function() {
            window.close();
        });
    });";
$this->Html->scriptBlock($scriptWindowMsg, array('inline' => false));
?>
<style>
    .td-payment-record{
        
    }
    .right{
        text-align: right;
        padding-right: 3px;
        font-weight: bold;
        background-color: yellow;
    }
</style>
<div class="header clearfix">
    <div class="head-logo">
        <?php echo $this->Html->image('/img/aih/ARBL FULL Logo Letterhead Footer JPG r.jpg'); ?>
    </div>
</div>
<div class="title-body-content"><?php echo $title_for_layout; ?></div>
<div class="wrapper-table clearfix" style="overflow:auto; padding-bottom: 10px;">
    <table class="tbl-broking" border="0" style="border-left: none;">
        <thead>
            <tr class="title-tbl" >
                <td class="td-payment-record"><?php echo __('No'); ?></td>
                <td class="td-payment-record"><?php echo __('Payer'); ?></td>
                <td class="td-payment-record"><?php echo __('Payee'); ?></td>
                <td class="td-payment-record"><?php echo 'Local Amount'; ?></td>
                <td class="td-payment-record"><?php echo __('Exchange'); ?></td>
                <td class="td-payment-record"><?php echo 'Converted Amount'; ?></td>
                <td class="td-payment-record"><?php echo __('Paid date'); ?></td>
            </tr>
        </thead>
        <?php
        $i = 0;
        $total = 0;
        $totalusd = 0;
        foreach ($paymentrecords AS $paymentrecord) {
            $i++;
        ?>
            <tr>
                <td class="td-payment-record"><?php echo $i; ?></td>
                <td class="td-payment-record"><?php echo $paymentrecord['Paymentrecord']['payer']; ?></td>
                <td class="td-payment-record"><?php echo $paymentrecord['Paymentrecord']['payee']; ?></td>
                <td class="td-payment-record right"><?php echo $paymentrecord['Paymentrecord']['currency'] . ' ' .number_format($paymentrecord['Paymentrecord']['amount'],2); ?></td>
                <td class="td-payment-record"><?php echo $paymentrecord['Paymentrecord']['exchange']; ?></td>
                <td class="td-payment-record right"><?php echo $paymentrecord['Paymentrecord']['exchange_to'] . ' ' . number_format($paymentrecord['Paymentrecord']['usd_amount'],2); ?></td>
                <td class="td-payment-record"><?php echo date('m/d/Y', strtotime($paymentrecord['Paymentrecord']['date'])); ?></td>
            </tr>
        <?php
            $total = $total + $paymentrecord['Paymentrecord']['amount'];
            $totalusd = $totalusd + $paymentrecord['Paymentrecord']['usd_amount'];
        }
        ?>
            <tr>
                <td class="td-payment-record" colspan="3" style="text-align: right; padding-right: 5px; font-weight: bold;border: none;"> TOTAL:</td>
                <td class="td-payment-record" style="border: none;text-align: right; padding-right: 3px;font-weight: bold;">
                    <?php echo number_format($total,2); ?>
                </td>
                <td class="td-payment-record" style="border: none;"></td>
                <td class="td-payment-record" style="border: none;text-align: right; padding-right: 3px;font-weight: bold;">
                    <?php echo number_format($totalusd,2); ?>
                </td>
                <td class="td-payment-record" style="border: none;"></td>
            </tr>
    </table>
    <div style="margin-top: 40px; margin-bottom: 10px; font-weight: bold; font-size: 12pt;">
        Summary
    </div>
    <table class="tbl-broking" style="width: 300px;">
        <tr>
            <td style="font-weight: bold; padding-left: 5px; text-align: left;">Total Amount</td>
            <td class="td-payment-record right"><?php echo $paymentrecords[0]['Paymentrecord']['currency'] . ' ' . number_format($total_amount,2); ?></td>
        </tr>
        <tr>
            <td style="font-weight: bold; padding-left: 5px; text-align: left;">Total Paid</td>
            <td class="td-payment-record right"><?php echo $paymentrecords[0]['Paymentrecord']['currency'] . ' ' . number_format($total,2); ?></td>
        </tr>
        <tr>
            <td style="font-weight: bold; padding-left: 5px; text-align: left;">Outstanding</td>
            <td class="td-payment-record right"><?php echo $paymentrecords[0]['Paymentrecord']['currency'] . ' ' . number_format($total_amount - $total,2); ?></td>
        </tr>
    </table>

</div>
<div class="wrapper-button-form clearfix">
    <div class="button-form clearfix">
        <div class="button-aihre button-blue"><a href="JavaScript:void(0)" title="CLOSE" id="close"><?php echo __('CLOSE'); ?></a></div>
    </div>
</div>
